package code._14thread._04control;

public class DaemonDemo {
    public static void main(String[] args) {
        System.out.println("main start");
        ThreadDaemon t = new ThreadDaemon();
        t.setDaemon(true);
        t.start();
        for (int i = 0; i < 3; i++) {
            System.out.println("main------"+i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        System.out.println("main  end");
    }
}

class ThreadDaemon extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(getName()+"-------"+i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
